package net.wwang.blog;

import lombok.extern.slf4j.Slf4j;
import net.wwang.blog.util.IDGenerateUtil;
import net.wwang.blog.util.RedisUtil;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

import javax.annotation.PostConstruct;
import java.util.Random;
import java.util.TimeZone;

@Slf4j
@SpringBootApplication
@EnableJpaAuditing
public class WebApp {

    public static void main(String[] args) {
        SpringApplication application = new SpringApplication(WebApp.class);
        application.setBannerMode(Banner.Mode.CONSOLE);
        application.run(args);
    }

    @Bean
    public IDGenerateUtil createIdWorker(){
        return new IDGenerateUtil(0,0);
    }

    @Bean
    public RedisUtil createRedisUtil(){
        return new RedisUtil();
    }

    @Bean
    public Random createRadom(){
        return new Random();
    }
    @PostConstruct
    void started() {
        //TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
        //TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
        TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
    }
}
